<template>
  <el-col :span="span"
          :xs="spanMap.xs"
          :sm="spanMap.sm"
          :md="spanMap.md"
          :lg="spanMap.lg"
          :xl="spanMap.xl"
          class="descriptions-item">
    <div class="descriptions-item-content">
      <div class="descriptions-item-label">{{ label }}：</div>
      <div class="descriptions-item-value">
        <slot v-if="$slots.content"
              name="content" />
        <div v-else
             class="default-value"
             :title="value">
          <Tooltip v-if="iconName"
                   :content="content"
                   :placement="placement">
            <icon-svg class-name="iconClass mr5"
                      :icon-name="iconName" />
          </Tooltip>
          {{ value || "--" }}
        </div>
      </div>
    </div>
  </el-col>
</template>

<script>
import Tooltip from "@components/basic/Tooltip.vue";
export default {
  name: "DescriptionItem",
  props: {
    spanMap: {
      type: Object,
      required: false,
      default: () => {
        return {};
      }
    },
    span: {
      type: Number,
      required: false,
      default: 24
    },
    label: {
      required: true
    },
    value: {
      required: false,
      default () {
        return "";
      }
    },
    placement: {
      type: String,
      default: 'top'
    },
    iconName: String,
    content: String
  },
  components: {
    Tooltip
  },
};
</script>

<style scoped lang="scss">
.iconClass {
  width: 14px;
  height: 14px;
}
.descriptions-item {
  padding-bottom: 16px;
  padding-right: 20px;
  span {
    display: inline-block;
  }
  .descriptions-item-content {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    color: var(--prev-color-text-black);
    font-size: 16px;
    line-height: 1.5;
    width: 100%;
    font-weight: 600;
    .descriptions-item-label {
      width: 110px;
      text-align: right;
      flex-grow: 0;
      flex-shrink: 0;
      color: var(--prev-color-text-silvergrey);
      font-weight: 400;
      font-size: 16px;
      line-height: 1.5;
    }
    .descriptions-item-value {
      flex-grow: 1;
      overflow: hidden;
      .default-value {
        width: 99%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }
  }
}
</style>
